from django.db import models
from rest_framework.decorators import api_view


# Create your models here.
#用户表
class employee(models.Model):
    #性别设置为值只可选择两项
    GENDER_CHOLCES = [('F','女'),('M','男')]

    name = models.CharField(max_length=64,unique=True,verbose_name='姓名')
    password = models.CharField(max_length=32,verbose_name='密码')
    gender = models.CharField(max_length=32,choices=GENDER_CHOLCES,verbose_name='性别')
    age = models.IntegerField(verbose_name='年龄')
    department = models.CharField(max_length=32)
    # decimal_places保留后两位
    kpi = models.DecimalField(max_digits=5,decimal_places=2)
    address = models.CharField(max_length=64,default='北京',verbose_name='默认值')
    updatetime = models.DateTimeField(auto_now=True,verbose_name='更新时间')
    createtime = models.DateTimeField(auto_now_add=True,verbose_name='生成时间')

#用例表
class casedata(models.Model):
    casename = models.CharField(max_length=64,unique=True)
    status = models.CharField(max_length=64)
    step = models.TextField()
    expect = models.CharField(max_length=64)
    #关联用户表
    employee = models.ForeignKey(employee,on_delete=models.CASCADE,related_name='casedata',default=1)


#bug表
class bugdata(models.Model):
    title = models.CharField(max_length=64,unique=True,verbose_name='标题')
    step = models.TextField()
    expected = models.CharField(max_length=64,verbose_name='预期结果')
    actual = models.CharField(max_length=64,verbose_name='实际结果')
    status = models.CharField(max_length=64,verbose_name='状态')
    assigned = models.CharField(max_length=64,null=False,verbose_name='指派人')
    #关联用例表
    case = models.ForeignKey(casedata,on_delete=models.CASCADE,related_name='bugdata',verbose_name='外检关联')
    #关联用户表  后加的表字段 要加默认值
    employee = models.ForeignKey(employee, on_delete=models.CASCADE, related_name='bugdata',default=1)





